﻿//-----------------------------------------------------------------------
// <copyright file="TemplateTest.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
//-----------------------------------------------------------------------
#region Usings
using System;
using FastNET.CleanAct.Common.Repository.Interfaces.DataInterfaces.ManagementEngine;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Template = FastNET.CleanAct.Client.ManagerEngineData.Entities.Template;
#endregion

namespace FastNET.CleanAct.Testing.Client.ManagerEngineData.Entities
{
    /// <summary>
    /// Unit Tests for TemplateTest
    /// </summary>
    [TestClass]
    public class TemplateTest
    {
        /// <summary>
        /// Gets or sets the test context which provides
        /// information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext { get; set; }

        #region Name Validation

        /// <summary>
        /// Test for Name being Null
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Name_Null()
        {
            new Template { Name = null };
        }

        /// <summary>
        /// Test for Name being Too Long
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Name_TooLong()
        {
            new Template { Name = string.Empty.PadRight(101, 'A') };
        }

        /// <summary>
        /// Test for Name being successful
        /// </summary>
        [TestMethod]
        public void Name_Success()
        {
            ITemplateData data = new Template { Name = "TestName" };
            Assert.AreEqual("TestName", data.Name, "Mismatched Data");
        }

        /// <summary>
        /// Test for Name being defaulted
        /// </summary>
        [TestMethod]
        public void Name_Default()
        {
            ITemplateData data = new Template();
            Assert.AreEqual(null, data.Name, "Mismatched Data");
        }

        #endregion

        #region IsBuiltIn Validation

        /// <summary>
        /// Test for IsBuiltIn being successful
        /// </summary>
        [TestMethod]
        public void IsBuiltIn_Success()
        {
            ITemplateData data = new Template { IsBuiltIn = true };
            Assert.AreEqual(true, data.IsBuiltIn, "Mismatched Data");
        }

        /// <summary>
        /// Test for IsBuiltIn being defaulted
        /// </summary>
        [TestMethod]
        public void IsBuiltIn_Default()
        {
            ITemplateData data = new Template();
            Assert.AreEqual(false, data.IsBuiltIn, "Mismatched Data");
        }

        #endregion
    }
}
